function getMoney() {
  const getMoneyUrl = "getMoney";
  const moneyField = document.getElementById("money");
  fetch(getMoneyUrl)
  .then(response => {
    if (response.ok) return response.text();
    else throw new Error("request failed");
  })
  .then(money => {
    moneyField.textContent = money
  })
  .catch(error => {
    // if it fails wait 0.2s and repeat
    setTimeout(getMoney, 200);
  });

}
